home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!maverick
- From: maverick@netcom.com (Chris Shepard)
- Subject: Re: Locaton of an array?
- Message-ID: <maverickDL1u3x.45I@netcom.com>
- Sender: maverick@netcom6.netcom.com
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: Forte Free Agent 1.0.82
- References: <4d4iqk$hs3@overload.lbl.gov>
- Date: Fri, 12 Jan 1996 03:39:47 GMT
-
- Hi,
- Haven't actually coded this in a long time, but try....
-
- #include <the usual stuff>
-
- int main(void)
- {
- char arr[10],
- *p;
-
- p=arr;
- printf("addr of arr = %p\n",p);
- return(EXIT_SUCCESS);
- }
-
- Btw, just out of curiosity, why do you care where it lives in
- absolute RAM?
-
- Cheers.
-
-
- Mikhail Faiguenblat <mfaiguen> wrote:
-
- >I am sure this has been answered a million times by now, but could someody help
- >me, please?
-
- >I have an array in my program, and I need to find out the absolute location in
- >memory where this array is located.
- >I have tried to do it this way:
-
- >#include <stdio.h>
-
- >int main() {
- > char arr[10];
- > int addr;
-
- > printf("sizeof(char *) = %d\n", sizeof(char *));
- > printf("sizeof(int) = %d\n", sizeof(int));
-
- > addr = arr;
-
- > printf("addr = %d\n", addr);
-
- > return 0;
- >}
-
- >And it did not work:
-
- >sizeof(char *) = 4
- >sizeof(int) = 4
- >addr = 2063810808
-
- >Obviously, the computer I run it on does not have 2Gb memory, so I must be
- >doing something wrong.
- >Can anybody help me?
-
- >Mikhail
-
-
-
-